package cn.itcast.n5_共享模型_内存;

import lombok.extern.slf4j.Slf4j;

import static cn.itcast.util.Sleeper.sleep;

/**
 * <p>
 * Test01_可见性_可见性问题演示_退不出的循环
 * </p>
 *
 * @author flyduck
 * @since 2024/12/11
 */
@Slf4j(topic = "c.Test02_可见性_使用volatile解决可见性问题_退不出的循环")
public class Test02_可见性_使用volatile解决可见性问题_退不出的循环 {

    volatile static boolean run = true;

    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            while (run) {

            }
        });

        t.start();

        sleep(1);

        run = false;
    }

}
